/**
 * 项目名：化工企业安全生产信息化管理平台
 * 日期：    2020-03-01 22:19:08
 * Copyright (c) 2015- -版权所有
 */

package com.joysuch.wwyt.edu.repository;

import java.util.List;

import com.joysuch.wwyt.edu.entity.EduExamUserAnswer;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.querydsl.QuerydslPredicateExecutor;

/**
 * EduExamUserAnswerDao
 *
 */
public interface EduExamUserAnswerDao
        extends JpaRepository<EduExamUserAnswer, Long>, QuerydslPredicateExecutor<EduExamUserAnswer> {
    public Page<EduExamUserAnswer> findAll(Specification<EduExamUserAnswer> spec, Pageable pageable);

    public EduExamUserAnswer save(EduExamUserAnswer bean);

    public void delete(EduExamUserAnswer bean);

    List<EduExamUserAnswer> findByExamRecordId(Long examRecordId);

    @Query("from EduExamUserAnswer where questionId = ?1 and examRecordId = ?2")
    EduExamUserAnswer selectByQuestionId(Long questionId, Long examRecordId);


    @Query(value = "select count(*) from wwyt_edu_exam_user_answer where QUESTION_ID = ?1",nativeQuery = true)
    Long countByQuestionId(Long questionId);
}
